package com.doit.demo.day02.sources;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @DATE 2022/2/15/22:12
 * @Author MDK
 * @Version 2021.2.2
 *
 *
 *   1.readTextFile是多并行的Source
 *   2.既可以读取本地文件,也可以读取hdfs中的文件
 *   3.该Source创建的DataStream是一个有效的数据流(数据处理完成后,程序会退出)
 **/
public class FileSources1 {
    public static void main(String[] args) throws Exception {
        Configuration configuration = new Configuration();
        configuration.setInteger("rest.port",8081);
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> lines = env.readTextFile("C:\\Users\\MDK\\Desktop\\a.txt");
        //readTextFile()方法创建DataStream的并行度
        System.out.println("readTextFile方法创建的DataStream的并行度:"+lines.getParallelism());
        lines.print();
        env.execute();
    }
}
